﻿using Gx.Common;
using Gx.Dal.Manage;
using Gx.Model.Entity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace Gx.Bll.Manage
{
    public class E_DepLevelInfoBll
    {
       
        /// <summary>
        /// 获取部门数据列表
        /// </summary>
        /// <returns></returns>
        public List<E_DepLevelInfo> GetE_DepLevelInfoList(E_DepLevelInfo model)
        {
            StringBuilder strWhere = new StringBuilder();

            if (model.DepId > 0)
            {
                strWhere.AppendFormat(" AND  A.DepId={0}", model.DepId);
            }
            if (model.LevelId > 0)
            {
                strWhere.AppendFormat(" AND  A.LevelId={0}", model.LevelId);
            }

            if (model.Id > 0)
            {
                strWhere.AppendFormat(" AND  A.Id={0}", model.Id);
            }

            if (!model.LevelName.IsNullOrEmpty())
            {
                strWhere.AppendFormat(" AND  C.LevelName='{0}'", model.LevelName);
            }
            return GetE_DepLevelInfoList(strWhere.ToString());
        }

        public List<E_DepLevelInfo> GetE_DepLevelInfoList(string strWhere)
        {
            using (E_DepLevelInfoDal dal = new E_DepLevelInfoDal())
            {
                return dal.GetE_DepLevelInfoList(strWhere);
            }
        }

        /// <summary>
        /// 根据部门ID得到下面的所有级别(岗位)列表
        /// </summary>
        /// <returns></returns>
        public List<E_DepLevelInfo> GetE_DepLevelInfoList(int DepId)
        {
            return this.GetE_DepLevelInfoList(string.Format("  AND A.DepId={0}", DepId));
        }

        /// <summary>
        /// 获取部门数据列表
        /// </summary>
        /// <returns></returns>
        public List<E_DepLevelInfo> GetE_DepLevelInfoList()
        {
            return this.GetE_DepLevelInfoList(string.Empty);
        }

        /// <summary>
        /// 添加级别(岗位)信息
        /// </summary>
        /// <returns></returns>
        public bool AddE_DepLevelInfo(E_DepLevelInfo model)
        {
            using (E_DepLevelInfoDal dal = new E_DepLevelInfoDal())
            {
                return dal.AddE_DepLevelInfo(model);
            }
        }

        /// <summary>
        /// 根据LevelId更新DepId
        /// </summary>
        /// <returns></returns>)
        public bool EditE_DepLevelInfo(E_DepLevelInfo model)
        {
            using (E_DepLevelInfoDal dal = new E_DepLevelInfoDal())
            {
                return dal.EditE_DepLevelInfo(model);
            }
        }

        /// <summary>
        /// 删除级别(岗位)信息
        /// </summary>
        /// <returns></returns>
        public bool DelE_DepLevelInfo(E_DepLevelInfo model)
        {
            return true;
            //using (E_DepLevelInfoDal dal = new E_DepLevelInfoDal())
            //{
            //    return dal.DelE_DepLevelInfo(model);
            //}
        }
    }
}
